/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: add rtos no devmem support
 * Author: Abbott Liu <liuwenliang@huawei.com>
 * Create: 2023-09-05
 */

#ifndef __ARCH_RTOS_INTERNAL_LINEAR_H__
#define __ARCH_RTOS_INTERNAL_LINEAR_H__
#include <linux/irqdomain.h>

#ifdef CONFIG_RTOS_HAL_LINEAR_MAP

typedef irq_hw_number_t (*irq_domain_find_parent_t)(struct irq_domain *d,
				irq_hw_number_t hwirq);

void set_irq_domain_find_parent(irq_domain_find_parent_t find_hwirq_parent);

#ifdef CONFIG_HISILICON_IRQ_MBIGEN
extern bool irq_domain_is_mbigen(const struct irq_domain_ops *ops);
#else
static inline bool irq_domain_is_mbigen(const struct irq_domain_ops *ops)
{
	return false;
}
#endif

extern irq_domain_find_parent_t get_irq_domain_find_parent(void);

#ifdef CONFIG_STM32_EXTI
extern irq_hw_number_t stm32_exti_find_hwirq_parent(struct irq_domain *dm,
		irq_hw_number_t hwirq);
#endif

#ifdef CONFIG_GENERIC_MSI_IRQ
extern int get_msi_irq_base(void);
extern void add_msi_irq_base(unsigned int num);
#endif

#else /* CONFIG_RTOS_HAL_LINEAR_MAP */
static inline void set_irq_domain_find_parent(irq_hw_number_t (*find_hwirq_parent)
	(struct irq_domain *dm, irq_hw_number_t hwirq)) {}

#ifdef CONFIG_GENERIC_MSI_IRQ
static inline int get_msi_irq_base(void)
{
	return -1;
}

static inline void add_msi_irq_base(unsigned int num) {}
#endif

#endif /* CONFIG_RTOS_HAL_LINEAR_MAP */

#endif /* __ARCH_RTOS_INTERNAL_LINEAR_H__ */
